<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>新发生生产计划登记</title>
    <!-- Google Font: Source Sans Pro -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="../dist/css/adminlte.min.css">
    <!-- overlayScrollbars -->
    <link rel="stylesheet" href="../plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
    <style>
        .c{
            background-color: #bdbdbd;
        }
    </style>
</head>
<body onload="pageinfo()"><!-- type="text/css"  type="text/css" type="text/javascript"-->
    <link rel="stylesheet"  href="../css/bootstrap.min.css">
    <link rel="stylesheet"  href="../css/bootstrap-table.min.css">
    <script src="../js/jquery.min.js" ></script>
    <script src="../js/bootstrap.bundle.min.js" ></script>
    <script src="../js/bootstrap.min.js"  ></script>
    <script src="../js/bootstrap-table.min.js"  ></script>
    <script src="../js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../js/index.js"></script>
<!--action="../scjh/addscjh"-->
<h1 style="margin-left: 40%">表单生产计划</h1>
<button class=" btn-dark" onclick="add()" >添加产品</button>
   <form class="form-group"  method="post"><!-- onsubmit="return ck()"-->
       <div class="row">
           <div class="col">
               生产理由：<input name="" class="form-control">
           </div>
           <div class="col">
               生产人：<input name="" class="form-control"><!--到时候在改成下拉框-->
           </div>
       </div>
               登记人：<input name="" class="form-control" readonly id="user">
       <table id="cptab" class="table">
           <thead>
           <tr>
               <th>点选</th>
               <th>产品名称</th>
               <th>编号</th>
               <th>数量</th>
               <th>单价</th>
               <th>小计</th>
           </tr>
           </thead>
           <tbody>

           </tbody>


       </table>
       <textarea name="productDescribe" class="form-control" id="ms">

       </textarea><br>
       <span class="price" id="price">￥0.00</span>
       <button onclick="ck()" class="btn btn-outline-success">提交</button>
   </form>

    <div class="modal" tabindex="-1" role="dialog"  id="exampleModal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">添加产品</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <table id="MyTable">
                        <tr id="MyTr">
                            <td>产品名</td>
                            <td>产品编号</td>
                            <td>产品单价</td>
                            <td>操作</td>
                        </tr>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
<script>
    //checkbox单独选
    //手动填写数量
    function ck(){
        var a=$("tbody :checkbox:checked").length
        if(a==0){
            alert("请选择产品后在提交");
            return false;
        }else {
            var name="";
            var id="";
            var num="";
            $(":checkbox:checked").each(function (index,item) {
                num=num+$(item).parent().next().next().next().children().val()+","
                name=name+$(item).parent().next().children().val()+","
                id=id+$(item).parent().next().next().children().val()+","
            })

            console.log("name="+name+"id="+id)
          //  alert(num+"num,name="+name)
            $.post("../scjh/addscjh",{"productName":name,"productId":id,"amount":num,"register":$("#user").val(),"productDescribe":$("#ms").val()},function (date) {
                //传值
            },"json")

        }
    }


</script>
</body>
</html>